
import { Input, Radio } from "antd"
import lessModule from "./index.module.less"
import searchImage from "../../../../../../../../../../assets/image/homePage-search.png"
import { ChangeEvent, Fragment, useEffect, useState } from "react"
import { RadioChangeEvent } from "antd/lib"
import { $eventBus, $EventBus_off, $EventBus_on, $JudgePortableDevice } from "../../../../../../../../../../common/utils"
// 主页-调试测试页面-便携设备接入页面-编辑弹窗组件-选择站点组件-信息卡片组件
interface homePageDebuggingAndTestingPagePortableDeviceAccessPageSelectSubstationComponentInfoCardComponentInterface {
    type: string
}
const HomePage_DebuggingAndTestingPage_PortableDeviceAccessPage_SelectSubstationComponent_InfoCardComponent: React.FC<homePageDebuggingAndTestingPagePortableDeviceAccessPageSelectSubstationComponentInfoCardComponentInterface> = (props) => {
    const [substationNameList, setSubstationNameList] = useState<Array<string>>([])
    const [infoCardStatus, setInfoCardStatus] = useState<string>("")
    const substationList = [
        {
            name: "巡回中心0",
            children: [
                {
                    name: "站点000000000000000000000000000",

                },
                {
                    name: "站点1",

                },
                {
                    name: "站点2",

                },
                {
                    name: "站点3",

                },
                {
                    name: "站点4",

                },
                {
                    name: "站点5",

                },
            ]
        },
        {
            name: "巡回中心1",
            children: [
                {
                    name: "站点0",
                    children: [
                        {
                            name: "主变0"
                        }
                    ]
                }
            ]
        }
    ]


// 广播函数数据
const eventBusFuncData = {
    homePageDebuggingAndTestingPagePortableDeviceAccessPageSelectSubstationComponentRadioPanelComponent_data: (data) => {
        setSubstationNameList([...data["substationNameList"]])
        setInfoCardStatus(data["infoCardStatus"])
    }
}
    useEffect(() => {
        $EventBus_on(eventBusFuncData)
        return () => {
            $EventBus_off(eventBusFuncData)
        }
    }, [])

    return (
        <>
            {substationNameList?.length === $JudgePortableDevice(props.type, 1, 2) && <div
                className={lessModule["homePageDebuggingAndTestingPagePortableDeviceAccessPageSelectSubstationComponentInfoCardComponent"]}
                style={{ backgroundColor: infoCardStatus === "success" ? "#C6F3D7" : "#FFD8D2" }}
            >
                {
                    $JudgePortableDevice(props.type,
                        infoCardStatus === "success" ?
                            <>
                                <span className={lessModule["homePageDebuggingAndTestingPagePortableDeviceAccessPageSelectSubstationComponentInfoCardComponent-label"]}>站点信息</span>
                                <span>主变台数：{1}</span>
                                <span>监测主变：#{3}</span>
                                <span>可用主变：#{1}、#{2}</span>
                            </>
                            : <span>“{substationNameList[0]}”无可用主变位置！</span>
                        ,

                        infoCardStatus === "success" ?
                            <>
                                <span>可新建“{substationNameList[0]}{substationNameList[1]}线”！</span>
                            </>
                            : <span>已存在“{substationNameList[0]}{substationNameList[1]}线”！</span>


                    )
                }
            </div>}
        </>
    )
}

export default HomePage_DebuggingAndTestingPage_PortableDeviceAccessPage_SelectSubstationComponent_InfoCardComponent